<template>
  <div class="right slider">
    <img class="right-logo" src="../assets/userLogo.jpeg" alt="" />
    <div class="title">夜尽天明</div>
    <div class="right-content"></div>
    <div class="tags">
      <div class="title">标签云</div>
      <router-link
        v-for="item in state.list"
        class="item"
        :key="item.id"
         :to="`/articles?tag_id=${item.id}&tag_name=${item.name}`"
        >
      <!-- :to="{
          name: 'articles',
          params: { 'tag_id': item.id, 'tag_name': item.name },
        }" -->
        <span :key="item.id">{{ item.name }}</span>
      </router-link>
    </div>
    <div class="introduce">
      <div class="title">技术以内的 BB</div>
      <div class="content">
        <!-- <img style="width: 100%" src="../assets/logo.jpg" alt="全栈修炼" /> -->
      </div>
    </div>
    <div class="introduce">
      <div class="title">开源项目的 BB</div>
      <div class="content">
        <!-- <img style="width: 100%" src="../assets/logo.jpg" alt="前端GitHub" /> -->
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { GetTagList } from "../api/api";
import { reactive, onMounted } from "vue";
import { Params, TagsData } from "../type/index";
const state = reactive({
  isLoadEnd: false,
  isLoading: false,
  list: [] as Array<any>,
  total: 0,
  params: {
    keyword: "",
    pageNum: 1,
    pageSize: 100,
  } as Params,
});
onMounted(() => {
  handleSearch();
  // state.list=[{name:'123'},{name:'1242'},{name:'689'}]
});
const handleSearch = async (): Promise<void> => {
  state.isLoading = true;
  const res = await GetTagList(state.params);
  const data = res.data;
  console.log("data:", data);
  //  console.log(JSON.parse(data))
  state.list = [...state.list, ...data.list];
  // console.log(state.articlesList)
  state.total = data.count;
  state.params.pageNum++;
  state.isLoading = false;
  // if (state.total === state.list.length) {
  //   state.isLoadEnd = true;
  // }
};
</script>

<style scoped lang="less">
.slider {
  padding-top: 50px;
}
.right {
  text-align: center;
  .right-logo {
    width: 130px;
    border-radius: 50%;
    animation: mylogo 3s;
    -moz-animation: mylogo 3s; /* Firefox */
    -webkit-animation: mylogo 3s; /* Safari and Chrome */
    -o-animation: mylogo 3s; /* Opera */
    animation-iteration-count: infinite;
  }
  .title {
    font-size: 25px;
    font-weight: bold;
  }
  .right-content {
    padding: 10px 0 20px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    .item {
      display: inline-block;
      padding: 0 10px;
      color: #969696;
      border-right: 1px solid #eee;
      &:last-child {
        border-right: none;
      }
      .num {
        color: #333;
      }
    }
  }
  .introduce {
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    .title {
      font-size: 14px;
      color: #969696;
    }
    .content {
      color: #333;
      line-height: 26px;
      text-align: left;
      padding: 20px 0;
    }
    .footer {
      padding-bottom: 10px;
    }
  }
  .tags {
    min-height: 200px;
    padding: 5px 0 20px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #eee;
    .title {
      font-size: 14px;
      color: #969696;
    }
    .item {
      display: inline-block;
      cursor: pointer;
      padding: 5px 10px;
      border-radius: 5px;
      background-color: #eee;
      color: #333;
      margin: 10px 10px 0 0;
      text-decoration: none;
      &:hover {
        color: #409eff;
      }
    }
  }
  .classification {
    padding: 5px 0 20px 0;
    .title {
      font-size: 14px;
      color: #969696;
    }
    .item {
      text-align: center;
      padding: 10px;
      border-bottom: 1px solid #eee;
      color: #666;
      margin: 10px 10px 0 0;
    }
  }
}
@keyframes mylogo {
  0% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
  25% {
    transform: rotate(0deg) scale(1, 1);
    opacity: 0.8;
  }
  100% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
}

@-moz-keyframes mylogo {
  0% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
  25% {
    transform: rotate(0deg) scale(1, 1);
    opacity: 0.8;
  }
  100% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
}

@-webkit-keyframes mylogo {
  0% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
  25% {
    transform: rotate(0deg) scale(1, 1);
    opacity: 0.8;
  }
  100% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
}

@-o-keyframes mylogo {
  0% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
  25% {
    transform: rotate(0deg) scale(1, 1);
    opacity: 0.8;
  }
  100% {
    transform: rotate(0deg) scale(0.8, 0.8);
    opacity: 1;
  }
}
</style>
